<template>
    <infinite :onInfinite="onInfinite" class="absfit">
        <m-loading :show="!ajax_delay_once" class="fit"></m-loading>
        <div class="of">
            <coupon-item v-for="(i, index) in list" :data="i" :key="index"></coupon-item>
        </div>
    </infinite>
</template>
<script>
  import couponItem from './_item'

  export default {
    props: {
      state: {
        type: Number,
        default: 2
      }
    },
    data () {
      return {
        ajax_delay_once: false,
        list: []
      }
    },
    computed: {},
    methods: {
      async onInfinite (page) {
        let {obj: {dataList, total}} = await this.$get_delay_once('coupon/getCouponByState', {
          state: this.state,
          page
        })
        this.list.push(...dataList)
        return this.list.length < total
      }
    },
    components: {
      couponItem
    }
  }
</script>
<style type="text/scss" lang="scss" scoped>

</style>
